/**
 * Created by Administrator on 2015/6/1.
 */

var passport = require('passport')
    , LocalStrategy = require('passport-local').Strategy;

/**
 *  需要登录
 * */
exports.isLogin = function (req, res, next) {

    if (req.isAuthenticated()) {
        console.log('pass');
        return next();
    }

    res.redirect('/admin/login');
}

//验证用户是否为管理员
exports.isAdmin = function (req, res, next) {

    if (req.isAuthenticated() && req.session.passport.user.level === 'admin') {
        console.log('admin pass');
        return next();
    }

    res.redirect('/admin/login');
}